package com.viettel.core.entities.cms;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import com.viettel.core.enumtype.CmsUserType;
import com.viettel.core.enumtype.UserStatus;

/**
 *  TABLE USER QUAN LY CMS
 *  @author: ToanTM1
 *  @version: 2.1
 *  @since: 27-02-2014 - 17:60:23
 */

@Entity
@Table(name = "CMS_USER")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "CMS_USER_SEQ", allocationSize = 1)
public class CmsUser implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
	@Column(name = "ID")
//	@Index(name="CMS_USER_ID_PK")
	private Integer id;
	
	/**
	 * TEN DAY DU
	 */
	@Basic
	@Column(name = "NAME", length = 100)
	private String name;
	
	/**
	 * TEN KHONG DAU
	 */
	@Basic
	@Column(name = "NAME_TEXT", length = 100)
	private String nameText;
	
	/**
	 * TEN DANG NHAP
	 */
	@Basic
	@Column(name = "USERNAME", length = 100)
	private String userName;
	
	/**
	 * MAT KHAU DANG NHAP
	 */
	@Basic
	@Column(name = "PASSWORD", length = 100)
	private String password;
	
	/**
	 * SALT KEM THEO MAT KHAU
	 */
	@Basic
	@Column(name = "SALT", length = 100)
	private String salt;
	
	/**
	 * SO DIEN THOAI
	 */
	@Basic
	@Column(name = "PHONE", length = 50)
	private String phone;
	
	/**
	 * DIA CHI EMAIL
	 */
	@Basic
	@Column(name = "EMAIL", length = 50)
	private String email;
	
	/**
	 * MO TA
	 */
	@Basic
	@Column(name = "DESCRIPTION", length = 2000)
	private String description;
	
	/**
	 * TRANG THAI
	 */
	@Basic
	@Column(name = "STATUS", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.UserStatus"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="CMS_USER_STATUSX")
	private UserStatus status;
	
	/**
	 * THOI GIAN TAO
	 */
	@Basic
	@Column(name = "CREATED_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdTime;

	/**
	 * USER TAO
	 */
	@Basic
	@Column(name = "CREATED_USER", length = 50)
	private String createdUser;
	
	/**
	 * LOAI USER
	 */
	@Basic
	@Column(name = "TYPE", columnDefinition = "integer", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.CmsUserType"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="CMS_USER_TYPEX")
	private CmsUserType type;
	
	/**
	 * THOI GIAN UPDATE GAN DAY
	 */
	@Basic
	@Column(name = "LAST_UPDATE_PASSWORD")
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastUpdatePassword;
	
	/**
	 * TO BAO
	 */
	@ManyToOne(targetEntity = Media.class)
	@JoinColumn(name = "MEDIA_ID", referencedColumnName = "id")
	@ForeignKey(name = "CMS_USER_MEDIA_FK")
	private Media media;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	public String getCreatedUser() {
		return createdUser;
	}

	public void setCreatedUser(String createdUser) {
		this.createdUser = createdUser;
	}

	public CmsUserType getType() {
		return type;
	}

	public void setType(CmsUserType type) {
		this.type = type;
	}

	public String getNameText() {
		return nameText;
	}

	public void setNameText(String nameText) {
		this.nameText = nameText;
	}

	public Date getLastUpdatePassword() {
		return lastUpdatePassword;
	}

	public void setLastUpdatePassword(Date lastUpdatePassword) {
		this.lastUpdatePassword = lastUpdatePassword;
	}

	public UserStatus getStatus() {
		return status;
	}

	public void setStatus(UserStatus status) {
		this.status = status;
	}

	public Media getMedia() {
		return media;
	}

	public void setMedia(Media media) {
		this.media = media;
	}

	
}